import minimist from "minimist";

class Params {
  static cmd?: string = "";
  static params: { [field: string]: string } = {};
}

(() => {
  const p = process.argv.findIndex((v) => v.includes("server.ts") || v.includes("server.js"));
  const argv = process.argv.slice(p + 1);
  if (!argv.length) return;
  if (!argv[0].startsWith("--")) {
    Params.cmd = argv[0];
  }
  Params.params = minimist(argv);
})();

// 命令行参数
export const CmdParams = Object.freeze(Params);
